package wzs.arithmetics;


//题目：计算字符串中子串出现的次数  
public class Test_wzs31
{
	
	public static int times = 0;
	public static int index = 0;
	public static void main(String[] args)
	{
		System.out.println(getAppearTimes("cdabcdecdfgcdccd", "cd"));
	}
	
	public static int getAppearTimes(String string1, String string2)
	{
		index = string1.indexOf(string2);
		System.out.println("index-->"+index);
		if (index != -1&& index <= string1.length() - string2.length())
		{
			times++;
			getAppearTimes(string1.substring(index+string2.length()), string2);
		}
		System.out.println("times--"+ times);
		return times;
	}
}
